﻿Public Class frm_Parametro_Data

    Private Sub bCancelar_Click(sender As System.Object, e As System.EventArgs) Handles bCancelar.Click
        Me.Close()
    End Sub

    Private Sub bConfirmar_Click(sender As System.Object, e As System.EventArgs) Handles bConfirmar.Click
        Dim frmRecursos As New frm_relatorio
        Dim rpt As New rel_ocorrencias_negativa
        Try
            If (mtbDtInicial.Text = "") Then
                mtbDtInicial.Text = Date.Now
            End If

            If (mtbDtFinal.Text = "") Then
                mtbDtFinal.Text = Date.Now
            End If

            rpt.ParameterFields.Item(0).CurrentValues.AddValue(Date.Parse(mtbDtInicial.Text))
            rpt.ParameterFields.Item(1).CurrentValues.AddValue(Date.Parse(mtbDtFinal.Text))

            frmRecursos.crvRelatorios.ReportSource = rpt
            frmRecursos.ShowDialog()
        Catch ex As Exception
            MessageBox.Show("Erro", "Relatório Ocorrências Negativas", MessageBoxButtons.OK)
        End Try
        frmRecursos.Dispose()
        Me.Close()
        rpt = Nothing
    End Sub

    Private Sub frm_Parametro_Data_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Try
            mtbDtInicial.Text = Date.Now
            mtbDtFinal.Text = Date.Now
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical, "Erro")
        End Try
    End Sub
End Class